from selenium import webdriver
import time
from selenium.webdriver.common.by import By
from selenium.webdriver.support.select import Select

dr = webdriver.Chrome()
dr.get("file:///C:/Users/Administrator/Desktop/自动化测试网页/自动化测试网页/注册A.html")
dr.maximize_window()
time.sleep(2)
# 找到下拉框元素
e = dr.find_element(By.ID,"selectA")
# 实例化select
s = Select(e)
# 通过序号选择
s.select_by_index(1)
time.sleep(2)
# 通过value选择
s.select_by_value("gz")
time.sleep(2)
# 通过文字选择
s.select_by_visible_text("深圳")
time.sleep(2)
dr.quit()